home *** CD-ROM | disk | FTP | other *** search
-
- #ifndef STRING_H
- #define STRING_H
-
- /*
- * This file declares an Abstract data type String
- * for dealing with strings in C.
- */
-
- #include <string.h>
-
- typedef struct _string *String;
-
- struct _string
- {
- char *string;
- int mallocedSize;
- };
-
-
- /* Creates a string with the initial size, and returns it */
-
- String string_alloc(unsigned int size);
-
- /* Frees the string and its memory */
-
- void string_free(String str);
-
- /* Resizes the String, will use realloc or malloc based on freeString */
-
- void string_setSize(String str,unsigned int size,int freeString);
-
- /* returns the size */
-
- int string_length(String str);
-
- /* Sets the strings data to "", without freeing the space */
-
- void string_empty(String str);
-
- /* Copys the data in str2 to str */
-
- void string_setStringValue(String str,char *str2);
-
- /* Copys the data in str2 to str , constrained by numChar*/
-
- void string_setStringNValue(String str,char *str2, int numChar);
-
- /* Copys the strings data and returns it*/
-
- char * string_copyValue(String str);
-
- /* Appends a character to the string */
-
- void string_appendChar(String str,char c);
-
- /* Appends a char * to the string */
-
- void string_appendString(String str1,const char *str2);
-
- /* Appends a char * to the string, limited by numChar */
-
- void string_appendNString(String str1,const char *str2,int numChar);
-
- /* Convert the string to upper case */
-
- void string_toUpper(String str);
-
- /* Remove the first n characters */
-
- void string_crop(String str, int n);
-
- /* Remove the last n characters */
-
- void string_chop(String str, int n);
-
- #endif
-